using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>
    public class Test_LogControl
    {
        #region Local Variable
        private Test_LogDataAccess _objDAO;
        #endregion Local Variable

        #region Method
        public Test_LogControl()
        {
            _objDAO = new Test_LogDataAccess();
        }

        public Test_LogInfo Get(
        Int32 No,
        Int32 Line,
        ref string sErr)
        {
            return _objDAO.Get(
            No,
            Line,
            ref sErr);
        }

        public DataTable Get_ByNo(
     Int32 No,
     ref string sErr)
        {
            return _objDAO.Get_ByNo(No,ref sErr);
        }

        public DataTable GetAll(
        ref string sErr)
        {
            return _objDAO.GetAll(
            ref sErr);
        }

        public Int32 Add(Test_LogInfo obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }

        public string Update(Test_LogInfo obj)
        {
            return _objDAO.Update(obj);
        }

        public string Delete(
        Int32 No,
        Int32 Line
        )
        {
            return _objDAO.Delete(
            No,
            Line
            );
        }
        public Boolean IsExist(
        Int32 No,
        Int32 Line
        )
        {
            return _objDAO.IsExist(
            No,
            Line
            );
        }

        public DataTableCollection Get_Page(Test_LogInfo obj, string orderBy, int pageIndex, int pageSize, ref String sErr)
        {
            return _objDAO.Get_Page(obj, orderBy, pageIndex, pageSize, ref sErr);
        }

        public DataTable Search(String columnName, String columnValue, String condition, ref String sErr)
        {
            return _objDAO.Search(columnName, columnValue, condition, "", ref  sErr);
        }
        public string InsertUpdate(Test_LogInfo obj)
        {
            string sErr = "";
            if (IsExist(
            obj.No,
            obj.Line
            ))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            Test_LogInfo inf = new Test_LogInfo();
            return inf.ToDataTable();
        }

        public string TransferIn(DataRow row)
        {
            Test_LogInfo inf = new Test_LogInfo(row);
            return InsertUpdate(inf);
        }
        #endregion Method


        public int GetMaxNo()
        {
            return _objDAO.GetMaxNo();
        }

        public string Delete_TestNo(int maxNo)
        {
            BUS.Test_Log_AnswerControl ansCtr = new Test_Log_AnswerControl();
            string sErr = ansCtr.Delete_TestNo(maxNo);
            return sErr + "|" + _objDAO.Delete_TestNo(maxNo);
        }
        public int GetNoTemp(long idTest,string type)
        {
            return _objDAO.GetNoTemp(idTest, type);
        }

        public DataTable GetLogByNo(long No, ref string sErr)
        {
            return _objDAO.GetLogByNo(No, ref sErr);
        }
        public DataTable GetLogRandByNo(long No, ref string sErr)
        {
            return _objDAO.GetLogRandByNo(No, ref sErr);
        }
        


        public DataTable GetByUser(long idTest, long idUser, int createF, int createT, ref string sErr)
        {
            return _objDAO.GetByUser(idTest, idUser, createF, createT, ref  sErr);
        }

        public string Delete(long idTest, long idUrs, string type)
        {
            return _objDAO.Delete(idTest, idUrs, type);
        }
        public DataTable GetAll(long idUser, long idTest, ref string sErr)
        {
            return _objDAO.GetAll(idUser, idTest, ref sErr);
        }

        public DataTable Get_ByNoScore(int no, double score, ref string sErr)
        {
            return _objDAO.Get_ByNoScore(no, score, ref  sErr);
        }
    }
}
